/**
 * 文件名：SMSBroadcastReceiver.java
 * 全路径：com.mi.android.SMSBroadcastReceiver
 */
package com.mi.android;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.util.Log;

/**
 * 功能：短信功能的广播<br>
 * 作者：蒋睿立<br> 
 * 时间：2016年6月15日<br> 
 * 版本：
 * 
 */
public class SMSBroadcastReceiver extends BroadcastReceiver {

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context,
	 * android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connectivityManager != null) {
			NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo();
			for (int i = 0; i < networkInfos.length; i++) {
				State state = networkInfos[i].getState();
				if (NetworkInfo.State.CONNECTED == state) {
					Log.i(this.getClass().getName(), "有网络");
					if (Center.getInstance().sms(context, intent)) {
						Center.getInstance().launchMiShop(context);
					}
					break;
				}
			}
		}
		Log.i(this.getClass().getName(), "没有网络");
	}
}
